<?php

require './Common/ConnDB.php';
require './Common/config.php';
class Model
{

    protected $conn;

    function __construct()
    {
        $this->conn = new ConnDB('DB_TYPE', DB_HOST, DB_USER, DB_PWD, DB_DBNAME);
    }

    function upload($uploadpic,$filepath){
        $_FILES["img"]["name"]=$uploadpic;
        $suffix=strrchr($_FILES["img"]["name"],'.');//获取在文件名中最后一次出现
        $allowtype=array("jpg","jpeg","png","PNG","gif","JPG","Bmp","flv");
        if(!in_array(ltrim($suffix,'.'),$allowtype))
        {
            echo"文件类型为$suffix!<br/>";
            echo"文件类型不正确";
            exit;
        }

        $newname=date("YmdHis").rand(100,999).$suffix;
        echo $filepath.$newname.'<br/>';
        move_uploaded_file($_FILES["img"]['tmp_name'], $filepath.$newname);
        return $newname;

    }


}
?>